﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="spread_ip.aspx.cs" Inherits="backmanage_spreadsystem_spread_ip" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>网吧IP管理</title>
    <script type="text/javascript" src="../js/jquery1.6.2.js"></script>
	<script type="text/javascript" src="../external/jquery.bgiframe-2.1.2.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.core.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.widget.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.mouse.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.button.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.draggable.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.position.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.resizable.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.dialog.js"></script> 
	<script type="text/javascript" src="../js/jquery.effects.core.js"></script> 
	<script type="text/javascript" src="../js/jquery.ajax.upfile.js"></script>
    <link rel="stylesheet" href="../css/demos.css" />
    <link rel="stylesheet" href="../css/jquery.ui.all.css" />
    <script type="text/javascript">
    $(function(){
          $("#dialog-form").dialog("destory");
          var name = $( "#name" ),
				    ipaddress = $( "#ipaddress" ),
				    contact=$("#contact"),
				    tel=$("#tel"),
				    province=$("#province"),
				    city=$("#city"),
				    county=$("#county"),
				    district=$("#district"),
				    address=$("#address"),
				    spreaderid=$("#spreaderid"),
				    allFields = $( [] ).add( name ).add( ipaddress ).add(contact).add(tel).add(province).add(city).add(county).add(district).add(address).add(spreaderid),
				    tips = $( ".validateTips" );
                function updateTips(t)
                {
                  tips.text(t)	
                      .addClass("ui-state-highlight");
                  setTimeout(function(){
                      tips.removeClass("ui-state-highlight",1500);
                  },500);
                }
                function checkEmpty(e,n)
                {
                  if(e.val().length>0){
                     return true;}
                  else{
                     e.addClass("ui-state-error");
                     updateTips(n+"不能为空.");
                     return false;
                     }
                }
                function SpreadipAdd()
                {
                  var name=$("#name").val();
                  var ip=$("#ipaddress").val();
                  var contact=$("#contact").val();
                  var tel=$("#tel").val();
                  var province=$("#province").val();
                  var city=$("#city").val();
                  var district=$("#district").val();
                  var county=$("#county").val();
                  var address=$("#address").val();
                  var spreadid=$("#spreadid").val();
                  var flag;
                  $.ajax({
                       ansyc:false,
                       url:'../API/A_Spreadip.aspx',
                       type:'POST',
                       data:{
                             edit:'add',
                             n:name,
                             i:ip,
                             c:contact,
                             t:tel,
                             p:province,
                             ct:city,
                             d:district,
                             cy:county,
                             a:address,
                             s:spreadid
                       },
                       dataType:'json',
                       success:function(data){
                             flag=data.err;
                       }
                  });
                  return flag;
                }
                function SetDialogform(id)
                {
                   $("#name").val($("#"+id+" td:nth-child(1)").text());
                   $("#ipaddress").val($("#"+id+" td:nth-child(4)").text());
                   $("#contact").val($("#"+id+" td:nth-child(2)").text());
                   $("#tel").val($("#"+id+" td:nth-child(3)").text());
                   $("#province").val($("#"+id+" td:nth-child(5)").text());
                   $("#city").val($("#"+id+" td:nth-child(6)").text());
                   $("#district").val($("#"+id+" td:nth-child(7)").text());
                   $("#county").val($("#"+id+" td:nth-child(8)").text());
                   $("#address").val($("#"+id+" td:nth-child(9)").text());
                   $("#spreadid").val($("#"+id+" td:nth-child(10)").text());
                   $("#dialog-form").dialog({
                     autoOpen:false,
                     height:450,
                     width:600,
                     modal:true,
                     buttons:{
                               "修改":function(){
                                   var flag=true;
                                   allFields.removeClass("ui-state-error");
                                       
                                   flag=flag && checkEmpty(name,"网吧名称");
                                   flag=flag && checkEmpty(ipaddress,"网吧IP地址");
                                   flag=flag && checkEmpty(contact,"联系人");
                                   flag=flag && checkEmpty(tel,"联系电话");
                                   flag=flag && checkEmpty(province,"所属省");
                                   flag=flag && checkEmpty(city,"所属市");
                                   flag=flag && checkEmpty(district,"所属区");
                                   flag=flag && checkEmpty(county,"所属县");
                                   flag=flag && checkEmpty(address,"详细地址");
                                   if(flag)
                                   {
                                        SpreadipAdd();        
                                        SpreadipList();
                                        $(this).dialog("close");
                                   }
                               },
                               "取消":function(){
                                   $(this).dialog("close");
                               },
                             },
                      close:function(){allFields.val("").removeClass("ui-state-error");
                      },
          });
                }
                function SpreadipList()
                {
                  $.ajax({
                       ansyc:false,
                       url:'../API/A_Spreadip.aspx',
                       type:'POST',
                       data:{edit:'list'},
                       success:function(msg)
                       {
                          $("#spreadiplist tbody").text("");
                          $("#spreadiplist tbody").append(msg);
                           $(".update").button().click(function(){var id=$(this).parent().parent().attr("id");SetDialogform(id); $("#dialog-form").dialog("open");});
                       }
                  });
                }
          $("#dialog-form").dialog({
                     autoOpen:false,
                     height:450,
                     width:600,
                     modal:true,
                     buttons:{
                               "提交":function(){
                                   var flag=true;
                                   allFields.removeClass("ui-state-error");
                                       
                                   flag=flag && checkEmpty(name,"网吧名称");
                                   flag=flag && checkEmpty(ipaddress,"网吧IP地址");
                                   flag=flag && checkEmpty(contact,"联系人");
                                   flag=flag && checkEmpty(tel,"联系电话");
                                   flag=flag && checkEmpty(province,"所属省");
                                   flag=flag && checkEmpty(city,"所属市");
                                   flag=flag && checkEmpty(district,"所属区");
                                   flag=flag && checkEmpty(county,"所属县");
                                   flag=flag && checkEmpty(address,"详细地址");
                                   if(flag)
                                   {
                                        SpreadipAdd();        
                                        SpreadipList();
                                        $(this).dialog("close");
                                   }
                               },
                               "取消":function(){
                                   $(this).dialog("close");
                               },
                             },
                      close:function(){allFields.val("").removeClass("ui-state-error");
                      },
          });
          $("#create-user").button().click(function(){$("#dialog-form").dialog("open");});
          $("#spreadid").focus(function(){alert("test");});
          
          $(document).ready(function(){
                      SpreadipList();
                     
          });
          
    })
    </script>
    <style type="text/css">
        body { font-size: 62.5%; }
		label, input { display:block;}
		input.text { margin-bottom:12px; width:95%; padding: .4em; }
		fieldset { padding:0; border:0; margin-top:25px; }
		h1 { font-size: 1.2em; margin: .6em 0; }
		div#users-contain { width: 350px; margin: 20px 0; }
		div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
		div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
		.ui-dialog .ui-state-error { padding: .3em; }
    	.validateTips { border:1px transparent solid; padding: 0.3em; }
		.validateTips input{border:1}
		.text{border:1}
		div#img-size{ width:200px}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    网吧IP管理
    <a id="create-user">添加网吧IP</a>
    <table id="spreadiplist" name="spreadiplist">
      <thead>
        <tr>
          <td>名称</td>
          <td>联系人</td>
          <td>联系电话</td>
          <td>IP地址</td>
          <td>省</td>
          <td>市</td>
          <td>区</td>
          <td>县</td>
          <td>地址</td>
          <td>推广账号</td>
          <td>操作</td>
        </tr>
      </thead>
      <tbody>
      </tbody>
      <tfoot>
         <tr>
          <td colspan="11">
            一共100页 第一页
          </td>
        </tr>
      </tfoot>
    </table>
    <div id="dialog-form" title="添加网吧信息">
    <p class="validateTips">填写要添加的网吧信息.</p> 
    <fieldset>
    <table>
      <tr>
        <td colspan="2">
           <label for="name">网吧名称</label>
           <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
        </td>
        <td colspan="2">
           <label for="ipaddress">网吧IP地址</label>
           <input type="text" name="ipaddress" id="ipaddress" value="" class="text ui-widget-content ui-corner-all" />
        </td>
      </tr>
      <tr>
        <td colspan="2">
           <label for="contact">联系人</label>
           <input type="text" name="contact" id="contact" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        <td colspan="2">
           <label for="tel">联系电话</label>
           <input type="text" name="tel" id="tel" value="" class="text ui-widget-content ui-corner-all" />
        </td>
      </tr>
      <tr>
        <td>
           <label for="province">省</label>
           <input type="text" name="province" id="province" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        <td>
           <label for="city">市</label>
           <input type="text" name="city" id="city" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        <td>
           <label for="district">区</label>
           <input type="text" name="district" id="district" value="" class="text ui-widget-content ui-corner-all" />
        </td>
        <td>
           <label for="county">县</label>
           <input type="text" name="county" id="county" value="" class="text ui-widget-content ui-corner-all" />
        </td>
      </tr>
      <tr>
        <td colspan="4">
           <label for="address">地址</label>
           <input type="text" name="address" id="address" value="" class="text ui-widget-content ui-corner-all" />
        </td>
      </tr>
      <tr>
        <td colspan="4">
           <label for="spreadid">推广员</label>
           <input type="text" name="spreadid" id="spreadid" value="" class="text ui-widget-content ui-corner-all" />
        </td>
      </tr>
    </table>
    </fieldset>
    </div>
    </div>
    </form>
</body>
</html>
